package GUI;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;

import javax.swing.JPanel;

import util.Util;

public class InventoryPanel extends JPanel implements MouseListener {
	
	ItemContainerView container;
	BufferedImage equipImg;
	game.Character character;
	
	public InventoryPanel(){
		super();
		this.setMinimumSize(new Dimension(800, 410));
		this.setPreferredSize(new Dimension(800, 410));
		this.setMaximumSize(new Dimension(800, 410));
		this.container = new ItemContainerView(null);
		this.container.setSize(350, 230);
		this.container.setLocation(0, 350);
		add(this.container);
		this.container.addMouseListener(this);
		this.equipImg = ImageStorage.getImage("GUI/inventory.png");
		
		this.setLayout(null);
	}
	
	public void paintComponent(Graphics g){
		g.setColor(Color.pink);
		g.fillRect(0, 0, this.getWidth(), this.getHeight());
		g.drawImage(this.equipImg, 0, 0, null);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		
		if (e.getSource()==container && e.getClickCount() == 2){
			if (container.getSelectedItems().size() == 1){
				this.character.EquipItem(container.getSelectedItems().get(0));
			}
		}
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

}
